package com.etc.cloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author kalista
 * @Description
 * @Date 2020/8/24  14:31
 **/
@Configuration
public class GatewayConfig {


    @Bean
    public RouteLocator constom(RouteLocatorBuilder builder){

        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route" ,r -> r.path("/guoji").uri("https://news.baidu.com/guoji"));

        return routes.build();

    }

    @Bean
    public RouteLocator constom2(RouteLocatorBuilder builder){

        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route" ,r -> r.path("/guonei").uri("https://news.baidu.com/guonei"));

        return routes.build();

    }

    @Bean
    public RouteLocator constom3(RouteLocatorBuilder builder){

        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route" ,r -> r.path("/mil").uri("https://news.baidu.com/mil"));

        return routes.build();

    }
}
